{{ define "head" }}
  {{ if .Paginator.HasPrev -}}<link rel="prefetch" href="{{ .Paginator.Prev.URL }}">{{- end }}
  {{ if .Paginator.HasNext -}}<link rel="prefetch" href="{{ .Paginator.Next.URL }}">{{- end }}
{{ end }}

{{ define "main" }}
  {{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
  {{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}

  {{ $PageContext := . }}
  {{ if .IsHome }}
    {{ $PageContext = .Site }}
  {{ end }}
  {{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}

  <div class="posts">
    {{ range $paginator.Pages }}
    <div class="post on-list">
      <h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
      <div class="post-meta">
        {{ if .Date }}
          <span class="post-date">
            {{ .Date.Format ($.Site.Params.DateFormatList | default "2006-01-02") }}
          </span>
        {{ end }}

        {{ if .Params.tags }}
        <span class="">
          {{ range .Params.tags }}
            #<a href="{{ (urlize (printf "tags/%s" . )) | absURL }}/">{{ . }}</a>&nbsp;
          {{ end }}
        </span>
        {{ end }}
      </div>

      {{ if .Params.feature }}
        {{ if .Params.UseRelativeCover }}
          <img loading='lazy' src="{{ (printf "%s%s" .Permalink .Params.feature ) }}" class="post-cover" />
        {{ else }}
          <img loading='lazy' src="{{ .Params.feature | absURL }}" class="post-cover" />
        {{ end }}
      {{ end }}

      <div class="post-content">
        {{ .Summary }}
      </div>
      {{ if .Truncated }}
        <div><a class="read-more button" href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore | default "Read more" }} →</a></div>
      {{ end }}
    </div>
    {{ end }}
    {{ partial "pagination.html" . }}
  </div>
{{ end }}
